package com.homework.oop;

public class Auto {
  private int tires;
  private String color;
  private int weight;
  private int speed;

  public Auto(int tires, String color, int weight, int speed) {
    this.tires = tires;
    this.color = color;
    this.weight = weight;
    this.speed = speed;
  }

  public void speedUp(int n1) {
    this.speed += n1;
    System.out.println("已加速");
  }

  public void speedDown(int n1) {
    if (this.speed != 0) {
      this.speed -= n1;
      System.out.println("已减速");
    } else {
      System.out.println("已经停车，无法减速了");
    }
  }

  public void stop() {
    this.speed = 0;
  }

  @Override
  public String toString() {
    return "Auto{"
        + "tires="
        + tires
        + ", color='"
        + color
        + '\''
        + ", weight="
        + weight
        + ", speed="
        + speed
        + '}';
  }
}
